<template>
	<view class="classfly flex-between" v-if="typeList.length">
		<m-sliding  v-model="type" :obj="typeList" keys="categoryID" values="categoryName" :values="'tname'"></m-sliding>
		<view class="right flex-center" @click="Jump({url:'/pages/classfy/classfy',mode:4})">
			<m-icon color="#fff" size="48" type="icon-_fenlei" />
		</view>
	</view>
</template>

<script>
	import { GetGoodsTypePage } from '@/api/Goods.js'
	export default {
		name: 'sliding',
		data() {
			return {
				type: -1,
				typeList: ['绿茶', '红茶', '白茶', '乌龙茶', '黄茶'],
			};
		},
		watch: {
			tType() {
				return this.typeList[this.type]
			},
			children() {
				return this.typeList[this.type]['children']
			},
			type(val) {
				console.log('type==>', val)
				console.log('typeList==>', this.typeList)
				this.$emit('onChange', val == -1 ? val : this.typeList[val].id)
			},
		},
		mounted() {
			this.GetGoodsTypePage();
		},
		methods: {
			async GetGoodsTypePage() {
				const { list, success } = await GetGoodsTypePage({
					positions: '0',
					pid: 0,
					pageSize: 1000
				});
				this.typeList = list;
			},
		},

	}
</script>

<style lang="scss">
	.classfly {
		.right {
			margin-left: 13rpx;
			// width: 120rpx;
			height: 48rpx;
			// background: rgba(255, 255, 255, .2);
			border-radius: 24rpx;

			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #FFFFFF;

		}
	}
</style>